package com.rky.crowd.mvc.handler;

import com.rky.crowd.service.api.AdminService;
import com.rky.crowd.util.CrowdUtil;
import entity.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 0x_Jss
 * @date 2022年02月08日 19:24
 * @description
 */
@Controller
public class TestHandler {
    @Autowired
    private AdminService adminService;

    private Logger logger = LoggerFactory.getLogger(TestHandler.class);

    @ResponseBody
    @RequestMapping("/send/array/plan/three")
    public String receiveArrayPlanThree(@RequestBody Integer[] empIdArray) {
        for (Integer empId : empIdArray) {
            System.out.println(empId);
        }
        return "success";
    }

//    @ResponseBody
//    @RequestMapping("/send/array/two.html")
//    public String testReceiveArrayTwo(@RequestParam("array") List<Integer> array) {
//        for (Integer number : array) {
//            System.out.println("number=" + number);
//        }
//        return "success";
//    }
//
//    @ResponseBody
//    @RequestMapping("/send/array/one.html")
//    public String testReceiveArrayOne(@RequestParam("array[]") List<Integer> array) {
//        for (Integer number : array) {
//            System.out.println("number=" + number);
//        }
//        return "success";
//    }

    @RequestMapping("/test/ssm.html")
    public String testSsm(ModelMap modelMap, HttpServletRequest request) {
        boolean judgeResult = CrowdUtil.judgeRequestType(request);
        logger.info("judgeResult=" + judgeResult);
        List<Admin> adminList = adminService.getAll();
        modelMap.addAttribute("adminList", adminList);
        String a = null;
        System.out.println(a.length());
        return "target";
    }
}